<template>
	<view class="particulars">
		<view class="bg">
			<image src="/static/icon/white-back.png" @tap="nav"></image>
			<view>订单详情</view>
		</view>
		<orderDetails :d='d'></orderDetails>
	</view>
</template>

<script>
	import moment from "moment"
	import orderDetails from '@/components/hotel/order/order-details.vue'
	export default {
		data() {
			return {
				d:{}
			}
		},
		onLoad(e) {
			this.req({
				url:'both/Order',
				id:e.id,
				method:'get'
			},(res)=>{
				let resf = res.data.data;
				//修改对应状态，显示按钮，时间
				// subscribe_time 	订单创建时间 	(待接单)
				// create_time	 	接单时间     	(待打扫)
				// arrive_time	 	保洁到店时间		(待打扫)
				// clean_time	 	保洁完成时间		(待确认)
				// finish_time	 	订单完成时间		(已完成)
				// 格式时间戳
				if(resf.order.subscribe_time){
					resf.time1 = moment(resf.order.subscribe_time*1000).format('YYYY-MM-DD HH:mm');
				}
				if(resf.order.create_time){
					resf.time2 = moment(resf.order.create_time*1000).format('YYYY-MM-DD HH:mm');
				}
				if(resf.order_status){
					if(resf.order_status.create_time){
						resf.time3 = moment(resf.order_status.create_time*1000).format('YYYY-MM-DD HH:mm');
					}
					if(resf.order_status.arrive_time){
						resf.time4 = moment(resf.order_status.arrive_time*1000).format('YYYY-MM-DD HH:mm');
					}
					if(resf.order_status.clean_time){
						resf.time5 = moment(resf.order_status.clean_time*1000).format('YYYY-MM-DD HH:mm');
					}
					if(resf.order_status.finish_time){
						resf.time6 = moment(resf.order_status.finish_time*1000).format('YYYY-MM-DD HH:mm');
					}
				}
				//修改对应状态，显示按钮，时间
				if(resf.order.order_state == 0){
					resf.title = '已取消';
					// resf.btn ='退款详情';
					resf.time = resf.time1
					resf.img ='/static/order/qx.png';
					this.d = resf;
					return;
				}
				if(resf.order.order_state == 10){
					resf.title = '待接单';
					resf.btn ='取消订单';
					resf.time = resf.time2
					resf.img ='/static/order/djd.png';
					this.d = resf;
					return;
				}
				if(resf.order.order_state == 20){
					resf.title = '待打扫';
					if(resf.order.order_state.arrive_time){
						resf.time = resf.time4
					}else{
						resf.time = resf.time3
					}
					resf.img ='/static/order/dds.png';
					this.d = resf;
					return;
				}
				if(resf.order.order_state == 30){
					resf.title = '待确认';
					resf.time = resf.time5
					resf.btn = '确认完成';
					resf.img = '/static/order/dqr.png';
					this.d = resf;
					return;
				}
				if(resf.order.order_state == 40){
					if(resf.order_status.evaluation_state == 0){
						resf.title = '待评价';
						resf.img ='/static/order/dpj.png';
						resf.btn = '立即评价';
						resf.time = resf.time6;
					}else{
						resf.title = '已评价';
						resf.img ='/static/order/wc.png';
						// resf.btn = '查看评价'
						resf.time7 = moment(resf.evaluate.create_time*1000).format('YYYY-MM-DD HH:mm');
						resf.btn = ''
						resf.time = resf.time7;
					}
		
					
					
					this.d = resf;
				}
			})
		},
		onShow(){
			// #ifdef APP-PLUS
				/**
				 * 启动时,状态栏变亮
				 */
			setTimeout(()=>{
				plus.navigator.setStatusBarStyle('light');	 
			},150); 
			// #endif
		},
		onUnload(){
			// #ifdef APP-PLUS
				/**
				 * 页面关闭时,状态栏变暗
				 */
				plus.navigator.setStatusBarStyle('dark');
			// #endif
		},
		methods:{
			nav(){
				uni.navigateBack();
			}
		},
		components:{
			orderDetails
		}
	}
</script>

<style lang="scss" scoped>
.particulars{
	background: #f8f8f8;
	.bg{
		width: 750upx;
		padding-top: var(--status-bar-height);
		height: 86upx;
		background-color: #3595f9;
		position: fixed;
		left: 0;
		top: 0;
		font-size: 36upx;
		color: #fff;
		text-align: center;
		line-height: 86upx;
		image{
			position: absolute;
			width: 32upx;
			height: 32upx;
			left: 27upx;
			bottom: 27upx;
		}
	}
}
</style>